<template>
    <div class="">
        <!--<div class="login-title">公开课后台管理系统</div>-->

    </div>
</template>

<script>
    /* eslint-disable no-console */

    import { ApiCrmLogin } from "../common/js/api";

    export default {
        data() {
            return {
                theRequest: {},
                url: 'https://www.baidu.com/s?id=111&name=yourname'
            }

        },
        methods: {
            login() {
                let params = this.theRequest
                console.log(params)
                ApiCrmLogin(params).then(res => {

                    if(res.data.code === 0){
                        sessionStorage.setItem('YX-TOKEN', res.data.data);
                        sessionStorage.setItem('OPEN_CLASS_PLATFORM', JSON.stringify(this.ruleForm));
                        this.$message({
                            message: '访问成功',
                            type: 'success'
                        });
                        this.logining = false;
                        this.$router.push({ path: '/' });
                    }else {
                        //this.$router.push({path:'/err'})
                    }
                }).catch(() => {
                    this.$router.push({path:'/err'})
                });

            },
            GetRequest() {
                this.url = location.href; //获取url中"?"符后的字串
                if (this.url.indexOf("?") != -1) {
                    let str = this.url.substring(this.url.indexOf("?")+1);
                    var strs = str.split("&");
                    for(var i = 0; i < strs.length; i ++) {
                        this.theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
                    }
                }
                console.log(this.theRequest)
                return this.theRequest;
            }


        },
       created() {
           this.GetRequest()
           this.login()
           console.log(window.location.href)
       }

    }

</script>

<style lang="scss">

</style>
